JB.Deck = Class.create();

JB.Deck.prototype = {
    selected : null,
    elements:null,
    tabPos:'top',
    deckMode:'tab',
    showTab:true,
    
    sync : function() {
        
    },
    
    initialize: function(did) {
        this.id = did;
        this.tabPos = Element.readAttribute(tid, 'jb_tab_pos');
        if(this.tabPos)
            this.tabPos='top';
            
        this.deckMode = Element.readAttribute(tid, 'jb_deck_mode');
        if(this.deckMode)
            this.deckMode='tab';

        this.showTab = !(Element.readAttribute(tid, 'jb_show_tab')=='false');
        
        this.elements = document.getElementsByClassName(this.id+'-deck',did);
        this.tabs = document.getElementsByClassName(this.id+'-tab',did);
        
    },
    init:function () {
       this.rows=null;
    },    
    select:function(col) {
    }
};

JB.Decks = Class.create();
JB.Decks.prototype = {
    currentElement:null,
    decks: new Array(),
    create:function(id) {
        var deck = new JB.Deck(id);
        this.currentElement=deck;
        this.decks[this.decks.length]=deck;
        return deck;
    },
    
    findOrCreate:function(id) {
        var ele=this.find(id);
        if(ele==null) {
            ele = this.create(id);
        }else {
            this.currentElement=ele;
        }
        return ele;
    },
    find:function(id) {
        var ele=null;
        $A(this.elements).each(function(item) {
            if(item.id==id) {
                ele=item;
            }
        }
        );
        return ele;
    },
    
    
    _init:function(tid) {
       return this.findOrCreate(tid);
    },
    initialize: function(id) {
        this.id = id;
    },
    onSelect:function (e, pid, cid) {
        var t =  this._i(pid);
        if(cid)
            ele = $(cid);
        t.select(cid);
    }
}
JBDecks= new JB.Decks('seededDecks');//global
